package org.mm.service.impl;

import java.util.Date;
import java.util.List;

import org.mm.model.TherapyTaskEvent;
import org.mm.repository.TherapyTaskEventRepository;
import org.mm.service.TherapyTaskEventService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.google.common.collect.Lists;

/**
 * @author mtraversari
 */
@Service("therapyTaskEventService")
@Transactional
public class TherapyTaskEventServiceImpl implements TherapyTaskEventService {

	@Autowired
	private TherapyTaskEventRepository therapyTaskEventRepository;

	public List<TherapyTaskEvent> findAll() throws Exception {
		return Lists.newArrayList(therapyTaskEventRepository.findAll());
	}

	public TherapyTaskEvent findByTherapyTask(Long therapyTaskId, Date scheduledDate) throws Exception {
		return therapyTaskEventRepository.findByTherapyTask(therapyTaskId, scheduledDate);
	}

/*	public void save(List<TherapyTaskEvent> events) throws Exception {
		Iterable<TherapyTaskEvent> entities = Lists.newLinkedList(events);
		taskEventRepository.save(entities);
	}*/

	public TherapyTaskEvent save(TherapyTaskEvent therapyTaskEvent) throws Exception {
		return therapyTaskEventRepository.save(therapyTaskEvent);
	}
}
